import 'package:flutter/material.dart';
import 'package:zhongyiapp/pages/bookstore.dart';
import 'package:zhongyiapp/pages/consilia.dart';
import 'package:zhongyiapp/pages/test.dart';

class Indexscreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: SingleChildScrollView(
        child: Column(children: const [
          title1(),
          SizedBox(height: 30.0),
          title2(),
          SizedBox(height: 15.0),
          title4(),
          title5(),
        ]),
      ),
    );
  }
}

class title1 extends StatelessWidget {
  const title1({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      decoration: BoxDecoration(
        image: DecorationImage(
          image: AssetImage('assets/背景图4.jpg'),
          fit: BoxFit.cover,
          colorFilter: ColorFilter.mode(
            Colors.white.withOpacity(0.8),
            BlendMode.dstATop,
          ),
        ),
      ),
      child: SafeArea(
        child: Column(
          children: <Widget>[
            SizedBox(
              height: 35.0,
            ),
            Container(
              width: 300,
              height: 35,
              decoration: BoxDecoration(
                  color: Colors.white,
                  borderRadius: BorderRadius.all(Radius.circular(20.0))),
              child: Row(
                children: [
                  SizedBox(width: 8.0),
                  Icon(Icons.search),
                  SizedBox(width: 8),
                  Expanded(
                    child: TextField(
                      decoration: InputDecoration(
                        hintText: '耳鸣',
                        border: InputBorder.none,
                      ),
                      onSubmitted: (value) {
                        // 处理搜索逻辑
                        print('Search for: $value');
                      },
                    ),
                  ),
                  Icon(Icons.camera),
                  SizedBox(
                    width: 8.0,
                  )
                ],
              ),
            ),
            SizedBox(
              height: 27.0,
            ),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => Bookscreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Icon(
                        Icons.local_library,
                        size: 40.0,
                        color: Colors.white,
                      ),
                      Text('经典书籍',
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 23.0,
                              fontFamily: '行楷')),
                    ],
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(
                        context,
                        MaterialPageRoute(
                            builder: (context) => Consiliascreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Icon(
                        Icons.description,
                        size: 40.0,
                        color: Colors.white,
                      ),
                      Text('医案',
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 23.0,
                              fontFamily: '行楷')),
                    ],
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => Testscreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Icon(
                        Icons.quiz,
                        size: 40.0,
                        color: Colors.white,
                      ),
                      Text('医考',
                          style: TextStyle(
                              color: Colors.white,
                              fontSize: 23.0,
                              fontFamily: '行楷')),
                    ],
                  ),
                ),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

class title2 extends StatelessWidget {
  const title2({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
        child: Column(
      children: <Widget>[
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Bookscreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/中药2.png'), // 替换为您的图片路径
                    width: 50.0,
                    height: 50.0,
                    // 如果需要，可以设置颜色
                  ),
                  Text('中药', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Consiliascreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/学伤寒论2.png'), // 替换为您的图片路径
                    width: 50.0,
                    height: 50.0,
                    // 如果需要，可以设置颜色
                  ),
                  Text('学伤寒论', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Testscreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/听书2.png'), // 替换为您的图片路径
                    width: 50.0,
                    height: 50.0,
                  ),
                  Text('听书', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Testscreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/疾病百科2.png'), // 替换为您的图片路径
                    width: 50.0,
                    height: 50.0,
                  ),
                  Text('疾病百科', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
          ],
        ),
        SizedBox(
          height: 10.0,
        ),
        Row(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: <Widget>[
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Bookscreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/经络穴位2.png'), // 替换为您的图片路径
                    width: 50.0,
                    height: 50.0,
                  ),
                  Text('穴位', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Consiliascreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/舌苔检测2.png'), // 替换为您的图片路径
                    width: 50.0,
                    height: 50.0,
                  ),
                  Text('舌苔检测', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Testscreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/方剂2.png'),
                    width: 50.0,
                    height: 50.0,
                  ),
                  Text('方剂', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
            GestureDetector(
              onTap: () {
                // 处理点击事件，跳转到其他页面
                Navigator.push(context,
                    MaterialPageRoute(builder: (context) => Testscreen()));
              },
              child: Column(
                children: <Widget>[
                  Image(
                    image: AssetImage('assets/名家讲堂2.png'),
                    width: 50.0,
                    height: 50.0,
                  ),
                  Text('名家讲堂', style: TextStyle(fontSize: 20.0)),
                ],
              ),
            ),
          ],
        ),
      ],
    ));
  }
}

class title4 extends StatelessWidget {
  const title4({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 380,
      padding: EdgeInsets.all(16.0),
      decoration: BoxDecoration(
        color: const Color.fromARGB(255, 250, 249, 249),
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(20.0),
          topRight: Radius.circular(20.0),
        ),
      ),
      child: Column(
        children: <Widget>[
          // 第一行：左边文字右边按钮
          SizedBox(
            height: 10.0,
          ),
          Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: <Widget>[
              Text(
                '热门课程',
                style: TextStyle(fontSize: 26, fontFamily: '行楷'),
              ),
              ElevatedButton(
                onPressed: () {
                  // 按钮点击事件
                  print('Button pressed');
                },
                child: Row(
                  mainAxisSize: MainAxisSize.min, // 使按钮内容紧凑
                  children: <Widget>[
                    Text('更多内容'),
                    SizedBox(
                      width: 3.0,
                    ), // 按钮的文字
                    Icon(
                      Icons.arrow_forward,
                      color: Colors.white,
                      size: 18.0,
                    ), // 按钮的图标
                  ],
                ),
                style: ElevatedButton.styleFrom(
                  foregroundColor: Colors.white,
                  backgroundColor:
                      Color.fromARGB(255, 154, 136, 92), // 按钮前景色（文字颜色）
                ),
              ),
            ],
          ),
          SizedBox(
            height: 10.0,
          ),
          // 第二行：插入图片
          Image.asset('assets/中医理论基础.png'),
        ],
      ),
    );
  }
}

class title5 extends StatelessWidget {
  const title5({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return Container(
      width: 380,
      padding: EdgeInsets.all(16.0),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.only(
          topLeft: Radius.circular(20.0),
          topRight: Radius.circular(20.0),
        ),
      ),
      child: Column(
        children: <Widget>[
          SizedBox(
            height: 10.0,
          ),
          Row(
              mainAxisAlignment: MainAxisAlignment.spaceBetween,
              children: <Widget>[
                Text(
                  '热门听书',
                  style: TextStyle(fontSize: 26, fontFamily: '行楷'),
                ),
              ]),
          SizedBox(
            height: 8.0,
          ),
          Row(
              mainAxisAlignment: MainAxisAlignment.spaceEvenly,
              children: <Widget>[
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => Bookscreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Image(
                        image: AssetImage('assets/黄帝内经.jpg'),
                        width: 80.0,
                        height: 120.0,
                        // 如果需要，可以设置颜色
                      ),
                      Text('30.0万人看过',
                          style: TextStyle(fontSize: 10.0, color: Colors.grey)),
                    ],
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(
                        context,
                        MaterialPageRoute(
                            builder: (context) => Consiliascreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Image(
                        image: AssetImage('assets/伤寒论.jpg'),
                        width: 80.0,
                        height: 120.0,
                      ),
                      Text('40.0万人看过',
                          style: TextStyle(fontSize: 10.0, color: Colors.grey)),
                    ],
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => Testscreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Image(
                        image: AssetImage('assets/神农本草经.jpg'),
                        width: 80.0,
                        height: 120.0,
                      ),
                      Text('20.0万人看过',
                          style: TextStyle(fontSize: 10.0, color: Colors.grey)),
                    ],
                  ),
                ),
                GestureDetector(
                  onTap: () {
                    // 处理点击事件，跳转到其他页面
                    Navigator.push(context,
                        MaterialPageRoute(builder: (context) => Testscreen()));
                  },
                  child: Column(
                    children: <Widget>[
                      Image(
                        image: AssetImage('assets/汤头歌诀.jpg'),
                        width: 80.0,
                        height: 120.0,
                      ),
                      Text('11.9万人看过',
                          style: TextStyle(fontSize: 10.0, color: Colors.grey)),
                    ],
                  ),
                ),
              ])
        ],
      ),
    );
  }
}
